package com.itheima.server.controller;

import com.itheima.server.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author 阿鹏
 * @date 2021/1/29 21:07
 */
@RestController
@RequestMapping("comments")
public class CommentsController {

    @Autowired
    private CommentsService commentsService;

    @GetMapping
    public ResponseEntity findComments(String movementId, int page, int pagesize) {
        return commentsService.findComments(movementId, page, pagesize);
    }

    @PostMapping
    public ResponseEntity saveComments(@RequestBody Map map) {
        String publishId = (String) map.get("movementId");
        String comment = (String) map.get("comment");
        return commentsService.saveComments(publishId, comment);
    }
}
